package cn.com.coding.system.service.impl;

import cn.com.coding.common.utils.PageUtil;
import cn.com.coding.common.utils.Query;
import cn.com.coding.system.dao.UserSchoolCheckDao;
import cn.com.coding.system.domin.UserSchoolCheckEntity;
import cn.com.coding.system.domin.dto.UserSchoolCheckDto;
import cn.com.coding.system.service.UserSchoolCheckService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("userSchoolCheckService")
public class UserSchoolCheckServiceImpl extends ServiceImpl<UserSchoolCheckDao, UserSchoolCheckEntity> implements UserSchoolCheckService {

    @Override
    public PageUtil queryPage(Map<String, Object> params) {

        IPage<UserSchoolCheckDto> page = this.baseMapper.selectMyPage(
                new Query<UserSchoolCheckDto>().getPage(params),
                new QueryWrapper<UserSchoolCheckDto>().like("ui.user_name", params.get("name") != null ? params.get("name") : "")
                        .or().like("usc.school_name", params.get("name") != null ? params.get("name") : "")
        );

        return new PageUtil(page);
    }

    @Override
    public UserSchoolCheckDto getUserSchoolCheckDtoByPid(String pid) {
        return this.baseMapper.getUserSchoolCheckDtoByPid(pid);
    }

}